﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace shop
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            // url admin 
            //routes.MapRoute(
            //    name: "admin",
            //    url: "admin/{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            //    namespaces: new[] { "shop.Areas.admin.Controllers" }
            //).DataTokens.Add("Area", "admin");
        
            // chi tiet san pham

            routes.MapRoute("chitietsanpham", "san-pham/{tensanpham}-{MaSP}.html", new { controller = "SanPham", action = "chitiet",MaSP = UrlParameter.Optional}, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");
            // danh muc
            routes.MapRoute("danhmuc", "danh-muc/{tendanhmuc}-{type}-{ID}.html", new { controller = "Sanpham", action = "danhmuc",type=UrlParameter.Optional ,ID = UrlParameter.Optional }, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");

            routes.MapRoute("danhmuc2", "danh-muc/{tendanhmuc}-{type}-{ID}/trang/{page}.html", new { controller = "Sanpham", action = "danhmuc", type = UrlParameter.Optional, ID = UrlParameter.Optional, page = UrlParameter.Optional }, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");


            routes.MapRoute("muatheosanpham", "mua-theo-san-pham/{tendanhmuc}-{id}.html", new { controller = "danhmuc", action = "danhsachsanpham", id = UrlParameter.Optional }, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");
            routes.MapRoute("timkiem", "tim-kiem/{Search}.html", new { controller = "timkiem", action = "timkiem", Search = UrlParameter.Optional }, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");
            routes.MapRoute("timkiem2", "tim-kiem/{Search}/trang/{page}.html", new { controller = "timkiem", action = "timkiem", Search = UrlParameter.Optional,page=UrlParameter.Optional }, namespaces: new[] { "shop.Areas.Main.Controllers" }).DataTokens.Add("Area", "Main");
           
            // url home
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "shop.Areas.Main.Controllers" }
            ).DataTokens.Add("Area","Main");
        }
    }
}